<template>
  <div id="huishangdiv">
    <div v-if="listLoading||filesLoading" style="margin:20px;">正在加载...</div>
    <div v-else>
      <div v-if="mydata && mydata.length > 0" style="clear:both">
        <el-button  @click="pinggushow()" style="right:60px;position:fixed;z-index:999" type="success">查看质量评估</el-button>
        <el-card style="margin:0 0 20px 0">
          <div slot="header" class="clearfix">
            <b>整体整改方案</b>
          </div>
            <b>
              <span v-if="files&&files.length>0">
                <div v-for="(item,index) in files" :key="index">
                  <a href="javascript:void(0)" @click="download(item.id)">{{item.fileName}}.{{item.fileType}}</a>
                  <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template>
                  <br>
                </div>
              </span>
              <span v-else>无</span>
            </b>
        </el-card>
        <div style="padding:10px 0;">共 <b>{{mydata.length}}</b> 条</div>
        <el-card v-for="(item, index) in mydata" :key="index" keys class="" style="margin:0 0 20px 0">
          <div slot="header" class="clearfix">
            <span><b>存在问题&nbsp;{{index+1}}：</b>{{item.cuizaiweiti}}</span>
          </div>
          <div class="text item" style="line-height:180%">
            <b>整改措施：</b>{{item.cuoshi}}
          </div>
          <hr style="height:1px;border:0;margin:20px 0;background:#EBEEF5;overflow:hidden">
          <div class="text item" style="line-height:180%;">
            <b>完成时限：</b>{{item.wanchengshixian&&item.wanchengshixian!==''?item.Wanchengshixian:'长期坚持'}}&nbsp;&nbsp;&nbsp;&nbsp;<b>负责人：</b>{{item.zerenren}}&nbsp;&nbsp;&nbsp;&nbsp;<b>落实单位（内部机构）：</b>{{item.luoshidanwei}}
          </div>
          <hr style="height:1px;border:0;margin:20px 0;background:#EBEEF5;overflow:hidden">
          <div class="text item" style="line-height:180%;font-weight:bolder">
            备注：
          </div>
          <div class="text item" style="line-height:180%">
            {{item.remark}}
          </div>
        </el-card>
      </div>
      <div v-else style="padding:20px; font-size:14px;color:#999;text-align:center">暂无数据</div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    timestamp: '',
    leaders: []
  },
  data () {
    return {
      files: [],
      filesLoading: false,
      listLoading: false,
      mydata: null,
      banziBaogao: '全部',
      beipipingren: '全部',
      filterList: [],
      sumWenti: 0
    }
  },
  watch: {
    timestamp (val) {
      this.loaddata()
      this.getFiles()
    },
    '$store.state.link_hz' (val) {
      this.activeNameHuishang = this.$store.state.link_hz
    }
    // $refs.tree2.getCurrentNode()
  },
  methods: {
    pinggushow () {
      var params1 = {Link1: 'Pingjia'}
      this.$store.commit('tablink1', params1)
    },
    showfile (id) {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.shenghuohuiAPI + 'api/newFileInfo/download?download=false&id=' + id + '&t=' + new Date())
    },
    download (id) {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.shenghuohuiAPI + 'api/newFileInfo/download?download=true&id=' + id + '&t=' + new Date())
    },
    getFiles () {
      this.filesLoading = true
      this.$http
        .get(this.$http.defaults.shenghuohuiAPI + `api/shenghuohuiunit/getFiles?id=` + this.$route.params.id)
        .then(response => {
          this.filesLoading = false
          if (response.data.success === true) {
            console.log('获取成功')
            this.files = response.data.result
          } else {
            console.log('获取数据失败:' + response.data.message)
            this.$message({
              message: '获取数据失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
          this.filesLoading = false
        })
    },
    loaddata () {
      this.listLoading = true
      let para = {
        shenghuohuiunitId: this.$route.params.id,
        pageNum: 1,
        pageSize: 2000
      }
      this.$http
        .post(this.$http.defaults.shenghuohuiAPI + `api/newHhBanzizhenggai/queryByPage`, para)
        .then(response => {
          this.listLoading = false
          if (response.data.success === true) {
            console.log('获取成功')
            this.mydata = response.data.result.records
          } else {
            console.log('获取数据失败:' + response.data.message)
            this.$message({
              message: '获取数据失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
          this.listLoading = false
        })
    }
  }
}
</script>
<style scoped>
.el-form-item{
  margin:0;
}
</style>
<style>
#huishangdiv .el-form-item__label{
  font-size:16px;
}
.chuxi{
  color:green;
}
.nochuxi{
  color:red;
}
#huiyiyicheng .el-form-item__content{
  font-size:16px;
}
</style>
